package router

import (
	"fmt"
	"net/http"
	"study/controller"

	"github.com/gin-gonic/gin"
)

func Init() {
	fmt.Println("================加载路由==============")

	router := gin.Default()

	router.LoadHTMLFiles("static/**")

	//页面
	htmlGroup := router.Group("/html")
	htmlGroup.GET("/regist", func(c *gin.Context) {
		c.HTML(http.StatusOK, "html/regist.html", gin.H{
			"title": "Posts",
		})
	})

	//测试路由组
	testGroup := router.Group("/test")
	testGroup.GET("/hello", controller.Hello)
	testGroup.GET("/spider", controller.Spider)

	//测试路由组
	spiderGroup := router.Group("/spider")
	spiderGroup.GET("/spider", controller.Spider)

	// 指定端口号
	router.Run(":8080")
}
